<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>活动管理</title>

    <style>
        .x-nav{padding:0 20px;position:relative;z-index:99;border-bottom:1px solid #e5e5e5;line-height:39px;height:39px;overflow:hidden}

        .layui-table-cell {
            height: 100%;
            max-width: 100%;
        }
    </style>
<!--    解决layui复选框不居中显示的bug-->
    <style type="text/css">
        .layui-table-cell .layui-form-checkbox[lay-skin="primary"]{
            top: 50%;
            transform: translateY(-50%);
        }
    </style>
</head>
<body>

<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>服务管理</cite></a>
              <a><cite>活动管理</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

    <div class="layui-inline">
        <label class="layui-form-label">活动标题</label>
        <div class="layui-input-inline">
            <input type="text" name="liketitle" id="liketitle" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-inline">
        <div class="layui-input-inline">
            <button class="layui-btn" id="searchBtn" lay-submit
                    lay-filter="formDemo" data-type="reload" style="margin-left: 15px">
                <i class="layui-icon layui-icon-search"></i> 查询
            </button>
            <button class="layui-btn" id="reset">重置</button>
        </div>
    </div>


<div class="layui-col-xs10">
    <table id="activityTable" lay-filter="activityTable" ></table>
</div>

    <script type="text/javascript" src="layui/layui.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <link rel="stylesheet" href="layui/css/layui.css" type="text/css">
<script type="text/javascript">
    $(window).on('load',function() {
        let item = localStorage.getItem("code");
        if (item != 0) {
            window.location.href = "/login.jsp"
        }
    });
    layui.use(['element'], function(){
        var element=layui.element;
        element.init();
    });


    // var nowtime = new Date();
    // let yyyy = new Date().getFullYear();
    // let mm = new Date().getMonth() + 1;
    // let dd = new Date().getDate();
    // let hh = new Date().getHours();
    // let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes()
    //     :
    //     new Date().getMinutes();
    // let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds()
    //     :
    //     new Date().getSeconds();
    // nowtime = yyyy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss;

    layui.use(["table","form","upload","layer","tree","laydate"],function() {
        var table = layui.table;
        var form = layui.form;
        var upload = layui.upload;
        var layer = layui.layer;
        var tree = layui.tree;
        var laydate=layui.laydate;

        //渲染table表格=====开始
        table.render({
            elem: '#activityTable'
            ,page: true
            ,limit:5
            ,limits:[5,8,12]
            ,url: 'http://localhost:8888/hy-activity/showAllActivity' //数据接口
            ,cols: [[ //表头
                {field: 'id', title: '编号' }
                ,{field: 'title', title: '活动标题'}
                ,{field: 'content', title: '活动内容'}
                ,{field: 'place', title: '活动地点'}
                ,{field: 'hostUnits', title: '举办单位'}
                ,{field: 'beginTime',width:180, title: '开始时间'}
                ,{field: 'endTime', width:180,title: '结束时间'}
                ,{field: 'createTime', width:180,title: '创建时间'}
            ]]
        });

    })


    $('#searchBtn').on('click', function () {
        layui.use("table",function() {
            let table = layui.table;
            table.render({
                elem: '#activityTable'
                ,page: true
                ,limit:5
                ,limits:[5,8,12]
                ,where: {
                    liketitle:$('#liketitle').val()
                }
                ,url: 'http://localhost:8888/hy-activity/showAllActivity' //数据接口
                ,cols: [[ //表头
                    {field: 'id', title: '编号' }
                    ,{field: 'title', title: '活动标题'}
                    ,{field: 'content', title: '活动内容'}
                    ,{field: 'place', title: '活动地点'}
                    ,{field: 'hostUnits', title: '举办单位'}
                    ,{field: 'beginTime', title: '开始时间'}
                    ,{field: 'endTime', title: '结束时间'}
                    ,{field: 'createTime', title: '创建时间'}
                ]]
            });
        });
    });
    $("#reset").click(function(){
        $("input[type='text']").prop("value","");
    });


</script>
</body>
</html>
